Some docs about magic words and the new hooks.
authorRotem Liss <rotem@users.mediawiki.org>
Sun, 25 Jun 2006 19:45:31 +0000 (19:45 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Sun, 25 Jun 2006 19:45:31 +0000 (19:45 +0000)
docs/hooks.txt
docs/magicword.txt [new file with mode: 0644]

index 16db940..0da7d95 100644 (file)
@@ -241,6 +241,9 @@ you're going to add events to the MediaWiki code.
 $user: the User object about to be created (read-only, incomplete)
 $message: out parameter: error message to display on abort
 
+'AddMagicWordsXX': Add magic words to the language with the code XX (e.g. En, De).
+$magicWords: The magic words array in the specified language.
+
 'AddNewAccount': after a user account is created
 $user: the User object that was created. (Parameter added in 1.7)
 
diff --git a/docs/magicword.txt b/docs/magicword.txt
new file mode 100644 (file)
index 0000000..ee5a940
--- /dev/null
@@ -0,0 +1,40 @@
+magicword.txt
+
+Magic Words are some phrases used in the wikitext. They are defined in several arrays:
+* $magicWords (includes/MagicWord.php) includes their internal names ('MAG_XXX').
+* $wgVariableIDs (includes/MagicWord.php) includes their IDs (MAG_XXX, which are constants),
+  after their internal names are used for "define()".
+* Localized arrays (languages/LanguageXX.php) include their different names to be used by the users.
+
+The localized arrays keys are the internal IDs, and the values are an array, whose include their
+case-sensitivity and their alias forms. The first form defined is used by the program, for example,
+when moving a page and its old name should include #REDIRECT.
+
+Adding magic words should be done using several hooks:
+* "MagicWordMagicWords" should be used to add the internal name ('MAG_XXX') to $magicWords.
+* "MagicWordwgVariableIDs" should be used to add the ID (MAG_XXX constant) to $wgVariableIDs.
+* "AddMagicWordsXX" (XX is the language code, e.g. En or De) should be used to add the
+  different names of the magic word. Use both the localized name and the English name.
+
+For example:
+
+$wgHooks['MagicWordMagicWords'][] = 'wfAddCustomMagicWord';
+$wgHooks['MagicWordwgVariableIDs'][] = 'wfAddCustomMagicWordID';
+$wgHooks['AddMagicWordsEn'][] = 'wfAddCustomMagicWordEn';
+$wgHooks['AddMagicWordsEs'][] = 'wfAddCustomMagicWordEs';
+
+function wfAddCustomMagicWord( &$magicWords ) {
+       $magicWords[] = 'MAG_CUSTOM';
+}
+
+function wfAddCustomMagicWordID( &$magicWords ) {
+       $magicWords[] = MAG_CUSTOM;
+}
+
+function wfAddCustomMagicWordEn( &$magicWords ) {
+       $magicWords[MAG_CUSTOM] = array( 0, "#custom" );
+}
+
+function wfAddCustomMagicWordEs( &$magicWords ) {
+       $magicWords[MAG_CUSTOM] = array( 0, "#aduanero", "#custom" );
+}